package com.example.wendao.view.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.wendao.view.ui.fragment.InformationMessageForumFragment;
import com.example.wendao.view.ui.fragment.InformationMessageNewsFragment;

import java.util.HashMap;
import java.util.Map;

public class ViewInfoMessageAdapter extends FragmentStateAdapter {
    private Map<Integer, Fragment> tabFragmentsCreators = new HashMap<>();

    {
        tabFragmentsCreators.put(0, new InformationMessageNewsFragment());
        tabFragmentsCreators.put(1, new InformationMessageForumFragment());
    }

    public ViewInfoMessageAdapter(@NonNull Fragment fragment) {
        super(fragment);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return tabFragmentsCreators.get(position);
    }

    @Override
    public int getItemCount() {
        return tabFragmentsCreators.size();
    }
}
